home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume11 / starchart / part13 < prev    next >
Encoding:
Text File  |  1990-03-15  |  48.4 KB  |  1,644 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v11i041: starchart 3.2 Part 13/32
  3. from: ccount@ATHENA.MIT.EDU
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 11, Issue 41
  7. Submitted-by: ccount@ATHENA.MIT.EDU
  8. Archive-name: starchart/part13
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 13 (of 32)."
  17. # Contents:  observe/outsat.c starchart/readfile.c
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'observe/outsat.c' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'observe/outsat.c'\"
  21. else
  22. echo shar: Extracting \"'observe/outsat.c'\" \(23472 characters\)
  23. sed "s/^X//" >'observe/outsat.c' <<'END_OF_FILE'
  24. X/*
  25. X * outsat.c
  26. X * Output satellite, PostScript file for satellites
  27. X *
  28. X * Copyright (c) 1990 by Craig Counterman. All rights reserved.
  29. X *
  30. X * This software may be redistributed freely, not sold.
  31. X * This copyright notice and disclaimer of warranty must remain
  32. X *    unchanged. 
  33. X *
  34. X * No representation is made about the suitability of this
  35. X * software for any purpose.  It is provided "as is" without express or
  36. X * implied warranty, to the extent permitted by applicable law.
  37. X *
  38. X */
  39. X
  40. X#ifndef  lint
  41. Xstatic char rcsid[] =
  42. X  "$Header: outsat.c,v 1.7 90/02/25 16:38:03 ccount Exp $";
  43. X#endif
  44. X
  45. X
  46. X#include <stdio.h>
  47. X#include "observe.h"
  48. X#include "date.h"
  49. X
  50. X#ifndef FALSE
  51. X#define FALSE 0
  52. X#endif
  53. X#ifndef TRUE
  54. X#define TRUE 1
  55. X#endif
  56. X
  57. Xvoid outjs(), outjs_PS();
  58. Xvoid jupsat(), satsat();
  59. X
  60. X/* Output satellite, .PS file for satellites */
  61. Xvoid out_sat(o_sat, o_sat_PS, one_day, invert_sats, jd, moon_data, planets)
  62. X     FILE *o_sat, *o_sat_PS;
  63. X     int one_day, invert_sats;
  64. X     double jd;
  65. X     moon_data_t moon_data;
  66. X     planet_data_t planets[];
  67. X{
  68. X  sat_t jovesats[4], saturnsats[8];
  69. X  static int last_jd = 0;
  70. X  static int doing_saturn = FALSE;
  71. X
  72. X  jupsat(jd, planets[3], jovesats);
  73. X  satsat(jd, planets[4], saturnsats);
  74. X
  75. X
  76. X  if (jd < last_jd) {
  77. X    doing_saturn = TRUE;
  78. X  };
  79. X  last_jd = jd;
  80. X  if (!doing_saturn)
  81. X    outjs(o_sat, one_day, jd, jovesats, saturnsats, planets);
  82. X  outjs_PS(o_sat_PS, one_day, invert_sats, jd,
  83. X       jovesats, saturnsats, moon_data, planets);
  84. X}
  85. X
  86. X
  87. Xvoid outjs(outf, one_day, jd, jovesats, saturnsats)
  88. X     FILE *outf;
  89. X     int one_day;
  90. X     double jd;
  91. X     sat_t jovesats[], saturnsats[];
  92. X{
  93. X  int i;
  94. X  char datestr[15];
  95. X
  96. X
  97. X  jd_to_str(jd, datestr);
  98. X  fprintf(outf, "%s\n", datestr);
  99. X
  100. X  fprintf(outf,
  101. X  "Relative position in planet radii, +x west +y north, RA seconds east\n");
  102. X  fprintf(outf,
  103. X"Satellite     Relative position: x  y  z      R.A.      Dec.       mag\n");
  104. X  for (i = 0; i < 4; i++)
  105. X    fprintf(outf, "%-10.10s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
  106. X        jovesats[i].name, jovesats[i].dx, jovesats[i].dy, jovesats[i].dz,
  107. X        jovesats[i].dalpha/15.0, jovesats[i].ddelta,
  108. X        jovesats[i].mag);
  109. X  fprintf(outf, "\n");
  110. X  for (i = 0; i < 8; i++)
  111. X    fprintf(outf, "%-10.10s %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f\n",
  112. X        saturnsats[i].name, saturnsats[i].dx, saturnsats[i].dy,
  113. X        saturnsats[i].dz,
  114. X        saturnsats[i].dalpha/15.0, saturnsats[i].ddelta,
  115. X        saturnsats[i].mag);
  116. X
  117. X
  118. X  if (!one_day) fprintf(outf, "\f\n");
  119. X}
  120. X
  121. X#define CenterLine 288
  122. X#define DateY 720
  123. X#define JupY 580
  124. X#define SatY 396
  125. X#define JupOneRad 6
  126. X#define SatOneRad 3
  127. X#define JOrderOff 36
  128. X#define SOrderOff 144
  129. X
  130. X#define JupManyRad 4.5
  131. X#define SatManyRad 2.25
  132. X#define JupColumn 144
  133. X#define SatColumn 144
  134. X#define OrderOffset 72
  135. X#define DateOffset 192
  136. X
  137. X#define Fontname "/Times-Roman"
  138. X#define Bigsize 10
  139. X#define JSFontname "/Times-Roman"
  140. X#define JSmlsz 10
  141. X#define SSFontname "/Times-Roman"
  142. X#define SSmlsz 8
  143. X
  144. Xint n_called = 0;
  145. X
  146. X/* output postscript picture of jupiter and saturn */
  147. Xvoid outjs_PS(outf, one_day, invert_sats, jd,
  148. X          jovesats, saturnsats, moon_data, planets)
  149. X     FILE *outf;
  150. X     int one_day, invert_sats;
  151. X     double jd;
  152. X     sat_t jovesats[], saturnsats[];
  153. X     moon_data_t moon_data;
  154. X     planet_data_t planets[];
  155. X{
  156. X  int i, j;
  157. X  static int printed_header = FALSE;
  158. X  static int top = 720;
  159. X  static int last_jd = 0;
  160. X  static int doing_saturn = FALSE;
  161. X  char datestr[15];
  162. X  int zindex[9];
  163. X  double z[9];
  164. X  int yindex[9];
  165. X  double y[9];
  166. X  int xindex[9];
  167. X  double x[9];
  168. X  double beta_e_saturn;
  169. X  int psx, psy;
  170. X
  171. X  jd_to_str(jd, datestr);
  172. X
  173. X  n_called++;
  174. X
  175. X  beta_e_saturn = planets[4].rotation_elements.beta_e;
  176. X
  177. X  /* Start postscript */
  178. X  if (!printed_header) {
  179. X    fprintf(outf, "%%!\n");
  180. X    fprintf(outf, "%%Remove this header and the later footer\n");
  181. X    fprintf(outf,
  182. X     "%%    if you are adding the code to a starchart postscript file.\n");
  183. X    fprintf(outf,
  184. X"%%Place the function definitions after the chart header in that file.\n");
  185. X    if (!one_day) {
  186. X      fprintf(outf, "%%This file was produced for a multiple day display,\n");
  187. X      fprintf(outf,
  188. X"%% and is not suitable for use within a starpost output file.\n");
  189. X      fprintf(outf,
  190. X"%% Prepare charts for individual days\n");
  191. X    };
  192. X    fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  193. X    fprintf(outf, "\n");
  194. X    fprintf(outf, "1 setlinewidth 2 setlinecap\n");
  195. X    fprintf(outf, "[] 0 setdash 0 setgray\n");
  196. X    fprintf(outf, "/s {newpath 0 360 arc closepath fill} def\n");
  197. X    fprintf(outf, "/s0 {8 s} def\n");
  198. X    fprintf(outf, "/s1 {7 s} def\n");
  199. X    fprintf(outf, "/s2 {6 s} def\n");
  200. X    fprintf(outf, "/s3 {5 s} def\n");
  201. X    fprintf(outf, "/s4 {4 s} def\n");
  202. X    fprintf(outf, "/s5 {3.25 s} def\n");
  203. X    fprintf(outf, "/s6 {2.5 s} def\n");
  204. X    fprintf(outf, "/s7 {2.0 s} def\n");
  205. X    fprintf(outf, "/s8 {1.5 s} def\n");
  206. X    fprintf(outf, "/s9 {1.0 s} def\n");
  207. X    fprintf(outf, "/s10 {0.5 s} def\n");
  208. X    fprintf(outf, "%%\n%%\n%%\n%%End of header\n%%\n%%\n");
  209. X    fprintf(outf, "%%\n%%\n%%\n%%Begin definitions\n%%\n%%\n");
  210. X    fprintf(outf,
  211. X"/centershow { dup stringwidth pop 2 div neg 0 rmoveto show } def\n");
  212. X    fprintf(outf,
  213. X"/atshow10pt { dup stringwidth pop 2 div neg 3.5 neg rmoveto show } def\n");
  214. X
  215. X
  216. X    fprintf(outf,
  217. X "/array-centershow { /str-arr exch def /widthskip exch def\n");
  218. X    fprintf(outf, "  str-arr length widthskip mul 2 div neg 0 rmoveto\n");
  219. X    fprintf(outf, "  str-arr {\n");
  220. X    fprintf(outf, "    gsave show grestore\n");
  221. X    fprintf(outf, "    widthskip 0 rmoveto\n");
  222. X    fprintf(outf, "  } forall\n");
  223. X    fprintf(outf, "} def\n");
  224. X    fprintf(outf, "/array-vertshow { /str-arr exch def /lineskip exch def\n");
  225. X    fprintf(outf, "  0 str-arr length lineskip mul 2 div neg rmoveto\n");
  226. X    fprintf(outf, "  str-arr {\n");
  227. X    fprintf(outf, "    gsave\n");
  228. X    fprintf(outf, "      dup stringwidth pop 2 div neg 0 rmoveto show\n");
  229. X    fprintf(outf, "    grestore\n");
  230. X    fprintf(outf, "    0 lineskip rmoveto\n");
  231. X    fprintf(outf, "  } forall\n");
  232. X    fprintf(outf, "} def\n");
  233. X
  234. X    fprintf(outf, "/Textx 2 def\n");
  235. X    fprintf(outf, "/Texty 2 def\n");
  236. X
  237. X
  238. X    fprintf(outf, "%% x y r phase p_n beta_e chi\n");
  239. X    fprintf(outf, "/planet-with-phase {\n");
  240. X    fprintf(outf, "  /chi exch def /beta_e exch def /p_n exch def\n");
  241. X    fprintf(outf, "  /phase exch def\n");
  242. X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
  243. X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
  244. X    fprintf(outf, "    x y translate r r scale\n");
  245. X    if (invert_sats) {
  246. X      if (one_day)
  247. X    fprintf(outf, "    1 -1 scale\n");
  248. X      else
  249. X    fprintf(outf, "    -1 1 scale\n");
  250. X      };
  251. X    fprintf(outf, "    gsave p_n rotate\n");
  252. X    fprintf(outf, "      1 setgray\n");
  253. X    fprintf(outf, "      0 0 1.05 0 360 arc fill\n");
  254. X    fprintf(outf, "      0 setgray\n");
  255. X    fprintf(outf, "      0 0 1 0 360 arc stroke\n");
  256. X    fprintf(outf, "      gsave\n");
  257. X    fprintf(outf, "        1 beta_e cos scale\n");
  258. X    fprintf(outf, "        0 1 moveto 0 1.25 lineto stroke\n");
  259. X    fprintf(outf, "      grestore\n");
  260. X    fprintf(outf, "      gsave\n");
  261. X    fprintf(outf, "        1 beta_e sin scale\n");
  262. X    fprintf(outf, "        0 0 1 180 360 arc stroke\n");
  263. X    fprintf(outf, "      grestore\n");
  264. X    fprintf(outf, "    grestore %% restore p_n rotation\n");
  265. X    fprintf(outf, "    gsave\n");
  266. X    fprintf(outf, "      chi rotate\n");
  267. X    fprintf(outf, "      newpath\n");
  268. X    fprintf(outf, "      0 0 1 0 180 arcn\n");
  269. X    fprintf(outf, "      1 phase cos scale\n");
  270. X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
  271. X    fprintf(outf, "    grestore\n");
  272. X    fprintf(outf, "  grestore\n} def\n");
  273. X
  274. X  /* Saturn with rings, no satellites, with north pole and equator */
  275. X    fprintf(outf, "/saturn-with-phase  {\n");
  276. X    fprintf(outf, "  /chi exch def /beta_e exch def /p_n exch def\n");
  277. X    fprintf(outf, "  /phase exch def\n");
  278. X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
  279. X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
  280. X    fprintf(outf, "    x y translate r r scale\n");
  281. X    if (invert_sats) {
  282. X      if (one_day)
  283. X    fprintf(outf, "    1 -1 scale\n");
  284. X      else
  285. X    fprintf(outf, "    -1 1 scale\n");
  286. X      };
  287. X    fprintf(outf, "    gsave p_n rotate\n");
  288. X    fprintf(outf, "      gsave 1 beta_e sin scale newpath\n"); /* back ring */
  289. X    fprintf(outf, "        0 0 1.51 0 180 arc stroke\n");
  290. X    fprintf(outf, "        0 0 1.94 0 180 arc stroke\n");
  291. X    fprintf(outf, "        0 0 2.00 0 180 arc stroke\n");
  292. X    fprintf(outf, "        0 0 2.27 0 180 arc stroke\n");
  293. X    fprintf(outf, "      grestore\n");
  294. X    fprintf(outf, "      1 setgray\n");
  295. X    fprintf(outf, "      0 0 1.05 0 360 arc fill\n");
  296. X    fprintf(outf, "      0 setgray\n");
  297. X    fprintf(outf, "      0 0 1 0 360 arc stroke\n");
  298. X    fprintf(outf, "      gsave\n");
  299. X    fprintf(outf, "        1 beta_e cos scale\n");
  300. X    fprintf(outf, "        0 1 moveto 0 1.25 lineto stroke\n");
  301. X    fprintf(outf, "      grestore\n");
  302. X    fprintf(outf, "      gsave\n");
  303. X    fprintf(outf, "        1 beta_e sin scale\n");
  304. X    fprintf(outf, "        0 0 1 180 360 arc stroke\n");
  305. X    fprintf(outf, "      grestore\n");
  306. X    fprintf(outf, "    grestore %% restore p_n rotation\n");
  307. X    fprintf(outf, "    gsave\n");
  308. X    fprintf(outf, "      chi rotate\n");
  309. X    fprintf(outf, "      newpath\n");
  310. X    fprintf(outf, "      0 0 1 0 180 arcn\n");
  311. X    fprintf(outf, "      1 phase cos scale\n");
  312. X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
  313. X    fprintf(outf, "    grestore\n");
  314. X    fprintf(outf, "    gsave p_n rotate\n");
  315. X    fprintf(outf, "      gsave 1 beta_e sin scale newpath\n"); /* front ring */
  316. X    fprintf(outf, "        0 0 1.51 180 360 arc stroke\n");
  317. X    fprintf(outf, "        0 0 1.94 180 360 arc stroke\n");
  318. X    fprintf(outf, "        0 0 2.00 180 360 arc stroke\n");
  319. X    fprintf(outf, "        0 0 2.27 180 360 arc stroke\n");
  320. X    fprintf(outf, "      grestore\n");
  321. X    fprintf(outf, "    grestore\n");
  322. X    fprintf(outf, "  grestore\n} def\n");
  323. X
  324. X
  325. X    fprintf(outf, "/Luna-with-phase {\n");
  326. X    fprintf(outf, "  /chi exch def\n");
  327. X    fprintf(outf, "  /phase exch def\n");
  328. X    fprintf(outf, "  /r exch def /y exch def /x exch def gsave\n");
  329. X    fprintf(outf, "    0 setgray .01 setlinewidth\n");
  330. X    fprintf(outf, "    x y translate r r scale\n");
  331. X    if (invert_sats) {
  332. X      if (one_day)
  333. X    fprintf(outf, "    1 -1 scale\n");
  334. X      else
  335. X    fprintf(outf, "    -1 1 scale\n");
  336. X      };
  337. X    fprintf(outf, "    1 setgray\n");
  338. X    fprintf(outf, "    0 0 1.05 0 360 arc fill\n");
  339. X    fprintf(outf, "    0 setgray\n");
  340. X    fprintf(outf, "    0 0 1 0 360 arc stroke\n");
  341. X    fprintf(outf, "    gsave\n");
  342. X    fprintf(outf, "      chi rotate\n");
  343. X    fprintf(outf, "      newpath\n");
  344. X    fprintf(outf, "      0 0 1 0 180 arcn\n");
  345. X    fprintf(outf, "      1 phase cos scale\n");
  346. X    fprintf(outf, "      0 0 1 180 360 arc fill\n");
  347. X    fprintf(outf, "    grestore\n");
  348. X    fprintf(outf, "  grestore\n} def\n");
  349. X
  350. X
  351. X    /* Define satellites */
  352. X    for (i = 0; i < 4; i++) {
  353. X/*
  354. X      if (one_day) {
  355. X    fprintf(outf, "/%s {2 copy s%d\n", jovesats[i].name,
  356. X        (int) (jovesats[i].mag+0.5));
  357. X    fprintf(outf,
  358. X        "     Texty add exch Textx add exch moveto (%c%c) show\n",
  359. X        jovesats[i].name[0], jovesats[i].name[1]);
  360. X      } else {
  361. X    fprintf(outf, "/%s {s%d\n", jovesats[i].name,
  362. X        (int) (jovesats[i].mag+0.5));
  363. X      };
  364. X*/
  365. X      fprintf(outf, "/%s {s%d\n", jovesats[i].name,
  366. X          (int) (jovesats[i].mag+0.5));
  367. X      fprintf(outf, "     } def\n");
  368. X    };
  369. X
  370. X    fprintf(outf,
  371. X"%% Saturn satellites are shown 4 magnitudes brighter then they are\n");
  372. X    for (i = 0; i < 8; i++) {
  373. X      j = saturnsats[i].mag - 4 +0.5;
  374. X      if (j > 10) j = 10;
  375. X      fprintf(outf, "/%s {s%d\n", saturnsats[i].name, j);
  376. X      fprintf(outf, "     } def\n");
  377. X    };
  378. X
  379. X    /* Define Jupiter and saturn without satellites */
  380. X    fprintf(outf, "\n");
  381. X    fprintf(outf, "/Jupiter-body {3 copy newpath 0 360 arc 1 setgray fill\n");
  382. X    fprintf(outf, "    0 360 arc 0 setgray stroke} def\n");
  383. X
  384. X
  385. X    fprintf(outf,
  386. X      "/back-ring {/beta exch def /r exch def /y exch def /x exch def\n");
  387. X    fprintf(outf, "    newpath gsave x y translate 1 beta sin scale\n");
  388. X    fprintf(outf, "    0 0 r 1.51 mul 0 180 arc stroke\n");
  389. X    fprintf(outf, "    0 0 r 2.27 mul 0 180 arc stroke\n");
  390. X    fprintf(outf, "    grestore} def\n");
  391. X    fprintf(outf,
  392. X      "/front-ring {/beta exch def /r exch def /y exch def /x exch def\n");
  393. X    fprintf(outf, "    newpath gsave x y translate 1 beta sin scale\n");
  394. X    fprintf(outf, "    0 0 r 1.51 mul 180 360 arc stroke\n");
  395. X    fprintf(outf, "    0 0 r 2.27 mul 180 360 arc stroke\n");
  396. X    fprintf(outf, "    grestore} def\n");
  397. X    fprintf(outf, "\n");
  398. X    fprintf(outf, "/Saturn-body {/r exch def /y exch def /x exch def\n");
  399. X    fprintf(outf, "    /beta %f def\n", beta_e_saturn);
  400. X    fprintf(outf, "    x y r beta back-ring\n");
  401. X    fprintf(outf, "    x y r 0 360 arc 1 setgray fill\n");
  402. X    fprintf(outf, "    x y r 0 360 arc 0 setgray stroke\n");
  403. X    fprintf(outf, "    x y r beta front-ring\n");
  404. X    fprintf(outf, "} def\n");
  405. X
  406. X
  407. X    fprintf(outf, "\n");
  408. X    fprintf(outf, "\n");
  409. X
  410. X    printed_header = TRUE;
  411. X  };
  412. X
  413. X
  414. X
  415. X  /* Define Jupiter and saturn with satellites */
  416. X  /* Jupiter */
  417. X  /* Find drawing order */
  418. X  for (i = 0; i < 4; i++)
  419. X    z[i] = jovesats[i].dz;
  420. X  z[4] = 0.0;            /* Jupiter's body */
  421. X  HeapSort0(z, zindex, 5);
  422. X
  423. X  fprintf(outf, "/Jupiter ");
  424. X  fprintf(outf, " { /r exch def gsave translate\n");
  425. X  if (invert_sats) {
  426. X    if (one_day)
  427. X      fprintf(outf, "    1 -1 scale\n");
  428. X    else
  429. X      fprintf(outf, "    -1 1 scale\n");
  430. X  };
  431. X  fprintf(outf, "    %f rotate\n",
  432. X      planets[3].rotation_elements.p_n);
  433. X  for (i = 0; i < 5; i++) {
  434. X    if (zindex[i] < 4) {
  435. X      fprintf(outf, "    r %f mul r %f mul %s\n",
  436. X          jovesats[zindex[i]].dx,
  437. X          jovesats[zindex[i]].dy, jovesats[zindex[i]].name);
  438. X    } else {
  439. X      fprintf(outf, "    0 0 r Jupiter-body\n");
  440. X    };
  441. X  };
  442. X  fprintf(outf, "grestore } def\n");
  443. X  /* Define order string */
  444. X  for (i = 0; i < 4; i++)
  445. X    x[i] = -jovesats[i].dalpha;
  446. X
  447. X  if (invert_sats)
  448. X    if (!one_day)
  449. X      for (i = 0; i < 4; i++)
  450. X    x[i] = jovesats[i].dalpha;
  451. X      
  452. X  x[4] = 0.0;            /* Jupiter's body */
  453. X  HeapSort0(x, xindex, 5);
  454. X  for (i = 0; i < 5; i++)
  455. X    if (xindex[i] == 4) j = i;
  456. X
  457. X  fprintf(outf, "/Jup-order-array [");
  458. X  for (i = 0; i < (4 - 2*j); i++) fprintf(outf, " (  )");
  459. X  for (i = 0; i < 5; i++) {
  460. X    if (xindex[i] < 4) {
  461. X      fprintf(outf, " (%c%c)",
  462. X          jovesats[xindex[i]].name[0], jovesats[xindex[i]].name[1]);
  463. X    } else {
  464. X      fprintf(outf, " (J)");
  465. X    }
  466. X  };
  467. X  for (i = 0; i < (2*(j-2)); i++) fprintf(outf, " (  )");
  468. X  fprintf(outf, "] def\n\n");
  469. X  fprintf(outf, "\n");
  470. X
  471. X  /* Saturn */
  472. X  /* Find drawing order */
  473. X  for (i = 0; i < 8; i++)
  474. X    z[i] = saturnsats[i].dz;
  475. X  z[8] = 0.0;            /* Saturn's body */
  476. X  HeapSort0(z, zindex, 9);
  477. X
  478. X  fprintf(outf, "/Saturn ");
  479. X  fprintf(outf, " { /r exch def gsave translate\n");
  480. X  if (invert_sats) {
  481. X    if (one_day)
  482. X      fprintf(outf, "    1 -1 scale\n");
  483. X    else
  484. X      fprintf(outf, "    -1 1 scale\n");
  485. X  };
  486. X  fprintf(outf, "    %f rotate\n",
  487. X      planets[4].rotation_elements.p_n);
  488. X  for (i = 0; i < 9; i++) {
  489. X    if (zindex[i] < 8) {
  490. X      fprintf(outf, "    r %f mul r %f mul %s\n",
  491. X          saturnsats[zindex[i]].dx,
  492. X          saturnsats[zindex[i]].dy, saturnsats[zindex[i]].name);
  493. X    } else {
  494. X      fprintf(outf, "    0 0 r Saturn-body\n");
  495. X    };
  496. X  };
  497. X  fprintf(outf, "grestore } def\n");
  498. X
  499. X  /* Define order string */
  500. X  for (i = 0; i < 8; i++)
  501. X    x[i] = -saturnsats[i].dalpha;
  502. X
  503. X  if (invert_sats)
  504. X    if (!one_day)
  505. X      for (i = 0; i < 8; i++)
  506. X    x[i] = saturnsats[i].dalpha;
  507. X      
  508. X  x[8] = 0.0;            /* Saturn's body */
  509. X  HeapSort0(x, xindex, 9);
  510. X  for (i = 0; i < 9; i++)
  511. X    if (xindex[i] == 8) j = i;
  512. X  fprintf(outf, "/Sat-order-array [");
  513. X  for (i = 0; i < (8 - 2*j); i++) fprintf(outf, " (  )");
  514. X  for (i = 0; i < 9; i++) {
  515. X    if (xindex[i] < 8) {
  516. X      fprintf(outf, " (%c%c)",
  517. X          saturnsats[xindex[i]].name[0], saturnsats[xindex[i]].name[1]);
  518. X    } else {
  519. X      fprintf(outf, " (S)");
  520. X    }
  521. X  };
  522. X  for (i = 0; i < (2*(j-4)); i++) fprintf(outf, " (  )");
  523. X  fprintf(outf, "] def\n\n");
  524. X  fprintf(outf, "\n");
  525. X  fprintf(outf, "\n");
  526. X
  527. X  /* Vertical for saturn */
  528. X  for (i = 0; i < 8; i++)
  529. X    y[i] = saturnsats[i].ddelta;
  530. X
  531. X  if (invert_sats)
  532. X    if (one_day)
  533. X      for (i = 0; i < 8; i++)
  534. X    y[i] = -saturnsats[i].ddelta;
  535. X
  536. X  y[8] = 0.0;            /* Saturn's body */
  537. X  HeapSort0(y, yindex, 9);
  538. X  for (i = 0; i < 9; i++)
  539. X    if (yindex[i] == 8) j = i;
  540. X  fprintf(outf, "/Sat-yorder-array [");
  541. X  for (i = 0; i < (8 - 2*j); i++) fprintf(outf, " (  )");
  542. X  for (i = 0; i < 9; i++) {
  543. X    if (yindex[i] < 8) {
  544. X      fprintf(outf, " (%c%c)",
  545. X          saturnsats[yindex[i]].name[0], saturnsats[yindex[i]].name[1]);
  546. X    } else {
  547. X      fprintf(outf, " (S)");
  548. X    }
  549. X  };
  550. X  for (i = 0; i < (2*(j-4)); i++) fprintf(outf, " (  )");
  551. X  fprintf(outf, "] def\n\n");
  552. X  fprintf(outf, "\n");
  553. X  fprintf(outf, "\n");
  554. X
  555. X  /* Draw them */
  556. X  if (one_day) {
  557. X    fprintf(outf, "/jupiter {2 div Jupiter} def\n");
  558. X    fprintf(outf, "/saturn {2 div Saturn} def\n");
  559. X    fprintf(outf,
  560. X"%% The above \"jupiter\" and \"saturn\" can be called from starchart postscript\n");
  561. X    fprintf(outf, "%%End definitions\n");
  562. X    fprintf(outf,
  563. X      "%%Begin footer: Remove if inserted in starchart postscript file\n");
  564. X    for (i = 0; i < 5; i++) {
  565. X      psx = 72 + i*72;
  566. X      psy = 180;
  567. X      if (i != 4)
  568. X    fprintf(outf,"%d %d %f %f %f %f %f planet-with-phase\n", psx, psy,
  569. X        planets[i].size* 0.70866141732283465, /* 1 cm = 20 s */
  570. X        planets[i].phase,
  571. X        planets[i].rotation_elements.p_n,
  572. X        planets[i].rotation_elements.beta_e,
  573. X        planets[i].chi);
  574. X      else
  575. X    fprintf(outf,"%d %d %f %f %f %f %f saturn-with-phase\n", psx, psy,
  576. X        planets[i].size* 0.70866141732283465, /* 1 cm = 20 s */
  577. X        planets[i].phase,
  578. X        planets[i].rotation_elements.p_n,
  579. X        planets[i].rotation_elements.beta_e,
  580. X        planets[i].chi);
  581. X      fprintf(outf, "%d %d moveto (%s) centershow\n", psx, psy - 72,
  582. X          planets[i].name);
  583. X      fprintf(outf, "%d %d moveto (Meridian) centershow\n",
  584. X          psx, psy - 90);
  585. X      fprintf(outf, "%d %d moveto (%.0f\\312) centershow\n",
  586. X          psx, psy - 102,
  587. X          planets[i].rotation_elements.lambda_e);
  588. X    };
  589. X
  590. X    fprintf(outf, "504 180 36 %f %f Luna-with-phase\n",
  591. X        moon_data.phase, moon_data.chi);
  592. X    fprintf(outf, "504 108 moveto (Moon) centershow\n");
  593. X    fprintf(outf, "504 90 moveto (%.2f arcmin) centershow\n",
  594. X        moon_data.size/60.0);
  595. X
  596. X    psy = 48;
  597. X    psx = 72;
  598. X    fprintf(outf,
  599. X "%d %d moveto %f %d lineto stroke %f %d moveto (  1 cm = 20 arcsec) show\n",
  600. X        psx, psy, psx + 20*0.70866141732283465, /* 1 cm = 20 s */ psy,
  601. X        psx + 20*0.70866141732283465, psy);
  602. X        
  603. X    fprintf(outf, "%d %d moveto (%s) centershow\n",
  604. X        CenterLine, DateY, datestr);
  605. X
  606. X    psx = CenterLine;
  607. X    psy = DateY - 72;
  608. X    if (invert_sats) {
  609. X      fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto stroke\n",
  610. X          psx, psy + 12, psx, psy - 12, psx - 4, psy - 12 + 4);
  611. X      fprintf(outf, "%d %d moveto (N) atshow10pt\n", psx, psy - 12 - 9);
  612. X      fprintf(outf, "%d %d moveto (S) atshow10pt\n", psx, psy + 12 + 9);
  613. X    } else {
  614. X      fprintf(outf, "%d %d moveto %d %d lineto %d %d lineto stroke\n",
  615. X          psx, psy - 12, psx, psy + 12, psx + 4, psy + 12 - 4);
  616. X      fprintf(outf, "%d %d moveto (N) atshow10pt\n", psx, psy + 12 + 9);
  617. X      fprintf(outf, "%d %d moveto (S) atshow10pt\n", psx, psy - 12 - 9);
  618. X    };
  619. X    fprintf(outf, "%d %d moveto %d %d lineto stroke\n",
  620. X        psx-12, psy, psx+12, psy);
  621. X    fprintf(outf, "%d %d moveto (E) atshow10pt\n", psx - 12 - 9, psy);
  622. X    fprintf(outf, "%d %d moveto (W) atshow10pt\n", psx + 12 + 9, psy);
  623. X
  624. X
  625. X    fprintf(outf, "%d %d %d Jupiter\n", CenterLine, JupY, JupOneRad);
  626. X    fprintf(outf, "/MMwidth (MM) stringwidth pop def\n");
  627. X    fprintf(outf,
  628. X "%d MMwidth 2 div add %d moveto MMwidth Jup-order-array array-centershow\n",
  629. X        CenterLine, JupY-JOrderOff);
  630. X    fprintf(outf, "\n");
  631. X
  632. X    fprintf(outf, "%d %d %d Saturn\n", CenterLine, SatY, SatOneRad);
  633. X    fprintf(outf,
  634. X "%d MMwidth 2 div add %d moveto MMwidth Sat-order-array array-centershow\n",
  635. X        CenterLine, SatY-SOrderOff);
  636. X    fprintf(outf, "%d %d moveto 12 Sat-yorder-array array-vertshow\n",
  637. X        CenterLine + SOrderOff, SatY);
  638. X    fprintf(outf, "\n");
  639. X  } else {
  640. X    if (jd < last_jd) {
  641. X      doing_saturn = TRUE;
  642. X      fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  643. X      fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  644. X      if (invert_sats) {
  645. X    fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  646. X    fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  647. X      } else {
  648. X    fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  649. X    fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  650. X      };
  651. X      fprintf(outf, "showpage\n");
  652. X
  653. X      top = 720;
  654. X    };
  655. X    last_jd = jd;
  656. X    if (!doing_saturn) {
  657. X      fprintf(outf, "%d %d %f Jupiter\n", JupColumn, top, JupManyRad);
  658. X      fprintf(outf, "%s findfont %d scalefont setfont\n", JSFontname, JSmlsz);
  659. X      fprintf(outf,
  660. X "%f %d moveto (MM) stringwidth pop Jup-order-array array-centershow\n",
  661. X          JupColumn + 36*JupManyRad + OrderOffset, top);
  662. X      fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  663. X      fprintf(outf, "%f %d moveto (%s) show\n",
  664. X          JupColumn + 36*JupManyRad + DateOffset,
  665. X          top, datestr);
  666. X
  667. X      fprintf(outf, "\n");
  668. X      top -= 18;
  669. X      if (top <= 71) {
  670. X    fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  671. X    fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  672. X    if (invert_sats) {
  673. X      fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  674. X      fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  675. X    } else {
  676. X      fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  677. X      fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  678. X    };
  679. X    fprintf(outf, "showpage\n");
  680. X    top = 720;
  681. X      };
  682. X    } else {
  683. X      fprintf(outf, "%d %d %f Saturn\n", SatColumn, top, SatManyRad);
  684. X      fprintf(outf, "%s findfont %d scalefont setfont\n", SSFontname, SSmlsz);
  685. X      fprintf(outf,
  686. X "%f %d moveto (MM) stringwidth pop Sat-order-array array-centershow\n",
  687. X          SatColumn + 72*SatManyRad + OrderOffset, top);
  688. X      fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  689. X      fprintf(outf, "%f %d moveto (%s) show\n",
  690. X          SatColumn + 72*SatManyRad + DateOffset,
  691. X          top, datestr);
  692. X
  693. X      fprintf(outf, "\n");
  694. X      top -= 72;
  695. X      if (top <= 71) {
  696. X    fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  697. X    fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  698. X    if (invert_sats) {
  699. X      fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  700. X      fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  701. X    } else {
  702. X      fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  703. X      fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  704. X    };
  705. X    fprintf(outf, "showpage\n");
  706. X    top = 720;
  707. X      };
  708. X    };
  709. X  };
  710. X
  711. X  if (one_day)
  712. X    fprintf(outf, "showpage\n");
  713. X}
  714. X
  715. X/* End: called if multiple day */
  716. Xvoid out_sat_end(o_sat, outf, invert_sats, start_date, interval_days)
  717. X     FILE *o_sat, *outf;
  718. X     int invert_sats;
  719. X     double start_date, interval_days;
  720. X{
  721. X
  722. X  fprintf(outf, "%s findfont %d scalefont setfont\n", Fontname, Bigsize);
  723. X  fprintf(outf, "%d %d moveto (N) show\n", CenterLine, 756);
  724. X  fprintf(outf, "%d %d moveto (S) show\n", CenterLine, 36);
  725. X  if (invert_sats) {
  726. X    fprintf(outf, "%d %d moveto (E) show\n", 576, 360);
  727. X    fprintf(outf, "%d %d moveto (W) show\n", 36, 360);
  728. X  } else {
  729. X    fprintf(outf, "%d %d moveto (E) show\n", 36, 360);
  730. X    fprintf(outf, "%d %d moveto (W) show\n", 576, 360);
  731. X  };
  732. X  fprintf(outf, "showpage\n");
  733. X}
  734. END_OF_FILE
  735. if test 23472 -ne `wc -c <'observe/outsat.c'`; then
  736.     echo shar: \"'observe/outsat.c'\" unpacked with wrong size!
  737. fi
  738. # end of 'observe/outsat.c'
  739. fi
  740. if test -f 'starchart/readfile.c' -a "${1}" != "-c" ; then 
  741.   echo shar: Will not clobber existing file \"'starchart/readfile.c'\"
  742. else
  743. echo shar: Extracting \"'starchart/readfile.c'\" \(22399 characters\)
  744. sed "s/^X//" >'starchart/readfile.c' <<'END_OF_FILE'
  745. X/*
  746. X * readfile.c
  747. X * readstar routine
  748. X * Copyright (c) 1989 by Craig Counterman (email: ccount@athena.mit.edu)
  749. X * and Alan Paeth (awpaeth@watcgl)
  750. X * all rights reserved
  751. X *
  752. X * You may copy the program, compile it, and run it,
  753. X * but you may not try to make money off it, or pretend you wrote it.
  754. X * (This copyright prevents you from selling the program - the
  755. X *  author grants anyone the right to copy and install the program
  756. X *  on any machine it will run on)
  757. X */
  758. X
  759. Xstatic char rcsid[]="$Header: readfile.c,v 2.7 90/03/10 15:31:11 ccount Exp $";
  760. X
  761. X#include <stdio.h>
  762. X#include <math.h>
  763. X
  764. Xchar *malloc();
  765. X
  766. X
  767. X#ifndef SYSV
  768. X#include <strings.h>
  769. X#else
  770. X#include <string.h>
  771. X#endif
  772. X#include <ctype.h>
  773. X
  774. X#include "star3.h"
  775. X
  776. X#ifndef READMODE
  777. X#define READMODE "r"
  778. X#endif
  779. X#define OPENFAIL 0
  780. X#define LINELEN 82
  781. X
  782. X
  783. X/* PI / 180 = .0174532925199 */
  784. X#define DCOS(x) (cos((x)*.0174532925199))
  785. X#define DSIN(x) (sin((x)*.0174532925199))
  786. X#define DTAN(x) (tan((x)*.0174532925199))
  787. X#define DASIN(x) (asin(x)/.0174532925199)
  788. X#define DATAN2(x,y) (atan2(x,y)/.0174532925199)
  789. X#define MAX(a,b) ((a)>(b)?(a):(b))
  790. X#define MIN(a,b) ((a)<(b)?(a):(b))
  791. X
  792. X
  793. X/* read file function indirection to allow for use of alternate file readers */
  794. Xextern int (*readfile)();
  795. Xextern char *cur_file_name;
  796. X
  797. X/* Readstar globals */
  798. Xextern double obj_lat, obj_lon, obj_mag;
  799. Xextern char obj_type[3], obj_color[3], obj_label[3];
  800. Xextern char obj_constell[4], obj_name[LINELEN];
  801. Xextern char *obj_commnt, fileline[LINELEN];
  802. X
  803. X
  804. X/* constellation abbreviations */
  805. Xchar *con_table[] = {
  806. X  "   ",
  807. X  "AND",
  808. X  "ANT",
  809. X  "APS",
  810. X  "AQL",
  811. X  "AQR",
  812. X  "ARA",
  813. X  "ARI",
  814. X  "AUR",
  815. X  "BOO",
  816. X  "CAE",
  817. X  "CAM",
  818. X  "CAP",
  819. X  "CAR",
  820. X  "CAS",
  821. X  "CEN",
  822. X  "CEP",
  823. X  "CET",
  824. X  "CHA",
  825. X  "CIR",
  826. X  "CMA",
  827. X  "CMI",
  828. X  "CNC",
  829. X  "COL",
  830. X  "COM",
  831. X  "CRA",
  832. X  "CRB",
  833. X  "CRT",
  834. X  "CRU",
  835. X  "CRV",
  836. X  "CVN",
  837. X  "CYG",
  838. X  "DEL",
  839. X  "DOR",
  840. X  "DRA",
  841. X  "EQU",
  842. X  "ERI",
  843. X  "FOR",
  844. X  "GEM",
  845. X  "GRU",
  846. X  "HER",
  847. X  "HOR",
  848. X  "HYA",
  849. X  "HYI",
  850. X  "IND",
  851. X  "LAC",
  852. X  "LEO",
  853. X  "LEP",
  854. X  "LIB",
  855. X  "LMI",
  856. X  "LUP",
  857. X  "LYN",
  858. X  "LYR",
  859. X  "MEN",
  860. X  "MIC",
  861. X  "MON",
  862. X  "MUS",
  863. X  "NOR",
  864. X  "OCT",
  865. X  "OPH",
  866. X  "ORI",
  867. X  "PAV",
  868. X  "PEG",
  869. X  "PER",
  870. X  "PHE",
  871. X  "PIC",
  872. X  "PSA",
  873. X  "PSC",
  874. X  "PUP",
  875. X  "PYX",
  876. X  "RET",
  877. X  "SCL",
  878. X  "SCO",
  879. X  "SCT",
  880. X  "SER",
  881. X  "SEX",
  882. X  "SGE",
  883. X  "SGR",
  884. X  "TAU",
  885. X  "TEL",
  886. X  "TRA",
  887. X  "TRI",
  888. X  "TUC",
  889. X  "UMA",
  890. X  "UMI",
  891. X  "VEL",
  892. X  "VIR",
  893. X  "VOL",
  894. X  "VUL"
  895. X  };
  896. X
  897. X
  898. X/* typedefs for exact sizes of int */
  899. Xtypedef char int_8;
  900. Xtypedef short int int_16;
  901. Xtypedef long int int_32;
  902. X
  903. X/* BINFULL structure */
  904. Xstruct bfull_struct {
  905. X  int_32 lat;            /* RA in seconds * 1000 */
  906. X  int_32 lon;            /* Dec in seconds * 1000 */
  907. X  int_16 mag;            /* Mag * 1000 */
  908. X  char tycolb[6];        /* Type, color, label fields */
  909. X  int_8 consindx;        /* Index number of constellation */
  910. X  int_16 strlen;        /* length of name and comment field */
  911. X} binfull_in;
  912. X
  913. Xchar name_comment[LINELEN];
  914. X
  915. X/* BINOBJ structure */
  916. Xstruct bobj_struct {
  917. X  int_32 lat;            /* RA in seconds * 1000 */
  918. X  int_32 lon;            /* Dec in seconds * 1000 */
  919. X  int_16 mag;            /* Mag * 1000 */
  920. X  char type[2];            /* e.g. 'SD', 'CO' */
  921. X} binobj_in;
  922. X
  923. X/* BINSTAR structure */
  924. Xstruct bstar_struct {
  925. X  int_32 lat;            /* RA in seconds * 1000 */
  926. X  int_32 lon;            /* Dec in seconds * 1000 */
  927. X  int_16 mag;            /* Mag * 1000 */
  928. X} binstar_in;
  929. X
  930. X#ifndef NO_GSC
  931. X
  932. X#ifndef MAXPATHLEN
  933. X#define MAXPATHLEN 1025
  934. X#endif
  935. X
  936. X/* GSC data */
  937. Xstruct {
  938. X  double ra_deg, dec_deg, mag;
  939. X  int mag_band, class;
  940. X} GSC[100];
  941. Xint GSC_nlines;
  942. Xint GSC_ID = 0;
  943. Xint GSC_skip = FALSE;
  944. Xchar id_str[5];
  945. Xchar last_gsc[MAXPATHLEN] = "";
  946. X#endif /* NO_GSC */
  947. X
  948. X/* readstar reads from the file the information for one object, and
  949. X   loads the following variables:
  950. Xdouble obj_lat, obj_lon, obj_mag;
  951. Xchar obj_type[] ="SS", obj_color[3], obj_label[3];
  952. Xchar obj_constell[3], obj_name[LINELEN];
  953. Xchar *obj_commnt, fileline[LINELEN];
  954. X
  955. Xonly lat, lon, and mag are required.  type should default to 'SS',
  956. Xcolor, label, constell default to "  ", and the rest default to ""
  957. X*/
  958. Xint readstar(file, ftype)
  959. X     FILE *file;
  960. X     int ftype;
  961. X{
  962. X  char *ptr;
  963. X  double rah, ram, ras, dld, dlm, dl, inten;
  964. X  int i, j;
  965. X  int nchars;
  966. X  char m1;
  967. X
  968. X  if ((ftype != LINEREAD) && (ftype != BINFULL)
  969. X      && (ftype != BINOBJ) && (ftype != BINSTAR) && (ftype != GSCTYPE))
  970. X    return (TRUE);
  971. X  /* only LINEREAD, BINFULL, BINOBJ, BINSTAR and GSC supported at this time */
  972. X
  973. X  if (ftype == BINSTAR) {
  974. X    if (fread((char *) &binstar_in, sizeof(binstar_in), 1, file) != 1) {
  975. X      if (feof(file)) return TRUE;
  976. X      perror("Error reading input file");
  977. X      exit(2);
  978. X    }
  979. X
  980. X    obj_lat = ((double) binstar_in.lat) / 3600000L;
  981. X    obj_lon = ((double) binstar_in.lon) / 3600000L;
  982. X    obj_mag = ((double) binstar_in.mag) / 1000L;
  983. X    obj_type[0] = 'S';
  984. X    obj_type[1] = 'S';
  985. X    obj_color[0] = ' ';
  986. X    obj_color[1] = ' ';
  987. X    obj_label[0] = ' ';
  988. X    obj_label[1] = ' ';
  989. X    obj_constell[0] = ' ';
  990. X    obj_constell[1] = ' ';
  991. X    obj_constell[2] = ' ';
  992. X    obj_name[0] = '\0';
  993. X    obj_commnt = "";
  994. X
  995. X    strcpy(fileline, "");
  996. X  } else if (ftype == BINOBJ) {
  997. X    if (fread((char *) &binobj_in, sizeof(binobj_in), 1, file) != 1) {
  998. X      if (feof(file)) return TRUE;
  999. X      perror("Error reading input file");
  1000. X      exit(2);
  1001. X    }
  1002. X
  1003. X    obj_lat = ((double) binobj_in.lat) / 3600000L;
  1004. X    obj_lon = ((double) binobj_in.lon) / 3600000L;
  1005. X    obj_mag = ((double) binobj_in.mag) / 1000L;
  1006. X    obj_type[0] = binobj_in.type[0];
  1007. X    obj_type[1] = binobj_in.type[1];
  1008. X    obj_color[0] = ' ';
  1009. X    obj_color[1] = ' ';
  1010. X    obj_label[0] = ' ';
  1011. X    obj_label[1] = ' ';
  1012. X    obj_constell[0] = ' ';
  1013. X    obj_constell[1] = ' ';
  1014. X    obj_constell[2] = ' ';
  1015. X    obj_name[0] = '\0';
  1016. X    obj_commnt = "";
  1017. X
  1018. X    strcpy(fileline, "");
  1019. X  } else if (ftype == BINFULL) {
  1020. X    if (fread((char *) &binfull_in, sizeof(binfull_in), 1, file) != 1) {
  1021. X      if (feof(file)) return TRUE;
  1022. X      perror("Error reading input file");
  1023. X      exit(2);
  1024. X    }
  1025. X
  1026. X    if (binfull_in.strlen == 0)
  1027. X      strcpy(name_comment, "");
  1028. X    else {
  1029. X      if (fread((char *) name_comment, binfull_in.strlen, 1, file) != 1) {
  1030. X    perror("Error reading input file");
  1031. X    exit(2);
  1032. X      }
  1033. X      name_comment[binfull_in.strlen] = '\0';
  1034. X    }
  1035. X
  1036. X    obj_lat = ((double) binfull_in.lat) / 3600000L;
  1037. X    obj_lon = ((double) binfull_in.lon) / 3600000L;
  1038. X    obj_mag = ((double) binfull_in.mag) / 1000L;
  1039. X    obj_type[0] = binfull_in.tycolb[0];
  1040. X    obj_type[1] = binfull_in.tycolb[1];
  1041. X    obj_color[0] = binfull_in.tycolb[2];
  1042. X    obj_color[1] = binfull_in.tycolb[3];
  1043. X    obj_label[0] = binfull_in.tycolb[4];
  1044. X    obj_label[1] = binfull_in.tycolb[5];
  1045. X    strcpy(obj_constell,con_table[binfull_in.consindx]);
  1046. X
  1047. X    ptr = name_comment;
  1048. X    i = 0;
  1049. X    while (*ptr == ' ') ptr++;
  1050. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1051. X      obj_name[i++] = *ptr++;
  1052. X    obj_name[i] = '\0';
  1053. X    if ((*ptr == ',') && (*++ptr) && name_comment[0]) obj_commnt = ptr;
  1054. X    else obj_commnt = "";
  1055. X
  1056. X    strcpy(fileline, "");
  1057. X#ifndef NO_GSC
  1058. X  } else if (ftype == GSCTYPE) {
  1059. X#define Val(ch) (ch - '0')
  1060. X    if (strcmp(cur_file_name, last_gsc)) { /* New file */
  1061. X      fseek(file, 8640L, 0);
  1062. X      strcpy(last_gsc, cur_file_name);
  1063. X      if (fread((char *) id_str, 5, 1, file) != 1) {
  1064. X    if (feof(file)) return TRUE;
  1065. X    perror("Error reading input file");
  1066. X    exit(2);
  1067. X      };
  1068. X      GSC_ID = Val(id_str[0])*10000 +
  1069. X    Val(id_str[1])*1000 +
  1070. X    Val(id_str[2])*100 +
  1071. X    Val(id_str[3])*10 +
  1072. X    Val(id_str[4]);
  1073. X    };
  1074. X    GSC_skip = FALSE;
  1075. X    do {
  1076. X      if (id_str[0] == ' ') return TRUE;
  1077. X      i = 0;
  1078. X      do {
  1079. X    if (fread((char *) fileline, 40, 1, file) != 1) {
  1080. X      if (feof(file)) return TRUE;
  1081. X      perror("Error reading input file");
  1082. X      exit(2);
  1083. X    };
  1084. X    for (j = 0; j < 40; j++) if (fileline[j] == ' ') fileline[j] = '0';
  1085. X    /* We care about RA_DEG, DEC_DEG, MAG, MAG_BAND, CLASS, MULTIPLE */
  1086. X    /* We read the GSC_ID already to see if it is a continuation */
  1087. X    GSC[i].ra_deg = Val(fileline[0]) * 100.0 +
  1088. X      Val(fileline[1]) * 10.0 +
  1089. X      Val(fileline[2]) +
  1090. X      Val(fileline[4]) / 10.0 +
  1091. X      Val(fileline[5]) / 100.0 +
  1092. X      Val(fileline[6]) / 1000.0 +
  1093. X      Val(fileline[7]) / 10000.0 +
  1094. X      Val(fileline[8]) / 100000.0;
  1095. X    if (fileline[10] == '-')
  1096. X      GSC[i].dec_deg = -1 *
  1097. X        (Val(fileline[11]) +
  1098. X         Val(fileline[13]) / 10.0 +
  1099. X         Val(fileline[14]) / 100.0 +
  1100. X         Val(fileline[15]) / 1000.0 +
  1101. X         Val(fileline[16]) / 10000.0 +
  1102. X         Val(fileline[17]) / 100000.0);
  1103. X    else
  1104. X      GSC[i].dec_deg =  ((fileline[9] == '-') ? -1 : 1) *
  1105. X        (Val(fileline[10]) * 10.0 +
  1106. X         Val(fileline[11]) +
  1107. X         Val(fileline[13]) / 10.0 +
  1108. X         Val(fileline[14]) / 100.0 +
  1109. X         Val(fileline[15]) / 1000.0 +
  1110. X         Val(fileline[16]) / 10000.0 +
  1111. X         Val(fileline[17]) / 100000.0);
  1112. X    GSC[i].mag = Val(fileline[23]) * 10.0 +
  1113. X      Val(fileline[24]) +
  1114. X      Val(fileline[26]) / 10.0 +
  1115. X      Val(fileline[27]) / 100.0;
  1116. X    GSC[i].mag_band = Val(fileline[32])*10 + Val(fileline[33]);
  1117. X    GSC[i].class = Val(fileline[34]);
  1118. X    i++;
  1119. X    if (fread((char *) id_str, 5, 1, file) != 1) {
  1120. X      if (!feof(file)) {
  1121. X        perror("Error reading input file");
  1122. X        exit(2);
  1123. X      };
  1124. X    };
  1125. X    if (!feof(file)) {
  1126. X      j = Val(id_str[0])*10000 +
  1127. X        Val(id_str[1])*1000 +
  1128. X        Val(id_str[2])*100 +
  1129. X        Val(id_str[3])*10 +
  1130. X        Val(id_str[4]);
  1131. X    };
  1132. X      } while ((j == GSC_ID) && (!feof(file)) && (id_str[0] != ' '));
  1133. X      GSC_nlines = i;
  1134. X      GSC_ID = j;
  1135. X      /* for now just use first */
  1136. X/* There are many stars with class == 3, so we'll ignore class */
  1137. X/*      if (GSC[0].class == 0) {*/    /* is a star if class == 0 */
  1138. X    obj_lon = GSC[0].ra_deg;
  1139. X    obj_lat = GSC[0].dec_deg;
  1140. X    obj_mag = GSC[0].mag;
  1141. X    obj_type[0] = 'S';
  1142. X    obj_type[1] = 'S';
  1143. X    obj_color[0] = ' ';
  1144. X    obj_color[1] = ' ';
  1145. X    obj_label[0] = ' ';
  1146. X    obj_label[1] = ' ';
  1147. X    obj_constell[0] = ' ';
  1148. X    obj_constell[1] = ' ';
  1149. X    obj_constell[2] = ' ';
  1150. X    obj_name[0] = '\0';
  1151. X/*    obj_commnt = &fileline[0];*/
  1152. X    obj_commnt = "";
  1153. X    fileline[0] = '\0';
  1154. X    GSC_skip = FALSE;
  1155. X/* Ignoring class seems to be the right thing */
  1156. X/*      } else {*/            /* not a star, skip */
  1157. X/*    GSC_skip = TRUE;
  1158. X      };*/
  1159. X    } while (GSC_skip);
  1160. X#endif /* NO_GSC */
  1161. X  } else { /* LINEREAD */
  1162. X
  1163. X/*
  1164. X * file formats:
  1165. X * new
  1166. X064509-1643-14SDA1a CMASirius
  1167. X051432-0812015SDB8b ORIRigel
  1168. X * old
  1169. X064509-1643-146SSSirius
  1170. X051432-08120015SSRigel
  1171. X */
  1172. X
  1173. X    fgets(fileline, LINELEN, file);
  1174. X    if (feof(file)) return(TRUE);    /* IS AN ERROR or eof */
  1175. X    nchars = 0;
  1176. X    while (fileline[nchars++]);
  1177. X    nchars--;
  1178. X    nchars--;
  1179. X
  1180. X/*
  1181. X * sscanf of floats is TOOO slow:
  1182. X *     sscanf(fileline, "%2f%2f%2f%c%2f%2f ... );
  1183. X * use alternate:
  1184. X */
  1185. X#define F2(i) (((fileline[i]-'0')*10.0+fileline[i+1]-'0'))
  1186. X#define F3(i) (((fileline[i]-'0')*100.0+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1187. X#define F4(i) (((fileline[i]-'0')*1000.0+(fileline[i+1]-'0')*100+(fileline[i+2])-'0')*10+fileline[i+3]-'0')
  1188. X#define F3M(i) (((fileline[i]-'A'+10.0)*100+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1189. X    rah = F2(0);
  1190. X    ram = F2(2);
  1191. X    ras = F2(4);
  1192. X    dld = F2(7);
  1193. X    dlm = F2(9);
  1194. X/*
  1195. X * common code
  1196. X */
  1197. X#define DLDEGSEC 3600.0
  1198. X#define DLMINSEC 60.0
  1199. X#define RAHRSSEC 54000.0
  1200. X#define RAMINSEC 900.0
  1201. X#define RASECSEC 15.0
  1202. X
  1203. X
  1204. X    obj_lon = (RAHRSSEC*rah + RAMINSEC*ram + RASECSEC*ras)/DLDEGSEC;
  1205. X    dl = (DLDEGSEC*dld + DLMINSEC*dlm)/DLDEGSEC;
  1206. X    obj_lat = (fileline[6]  == '-') ? -dl : dl;
  1207. X    
  1208. X    /* set unknowns to blanks */
  1209. X    obj_color[0] = ' ';
  1210. X    obj_color[1] = ' ';
  1211. X    obj_color[2] = '\0';
  1212. X    obj_label[0] = ' ';
  1213. X    obj_label[1] = ' ';
  1214. X    obj_label[2] = '\0';
  1215. X    obj_constell[0] = ' ';
  1216. X    obj_constell[1] = ' ';
  1217. X    obj_constell[2] = ' ';
  1218. X    obj_constell[3] = '\0';
  1219. X    
  1220. X    if  (isdigit(fileline[14])) {
  1221. X    /*
  1222. X     * old reduced Yale catalog
  1223. X     */
  1224. X      inten = F3(12);
  1225. X      if (fileline[11] == '0' || fileline[11] == '+') obj_mag = inten/100.0;
  1226. X      else if (fileline[11] == '-') obj_mag = -inten/100.0;
  1227. X      else obj_mag = F4(11)/1000.0;    /* new feature for stars >= 10.0 mag */
  1228. X      
  1229. X      if (nchars > 15) {
  1230. X    obj_type[0] = fileline[15];
  1231. X    obj_type[1] = fileline[16];
  1232. X    ptr = &fileline[MIN(17,nchars)];
  1233. X    i = 0;
  1234. X    while (*ptr == ' ') ptr++;
  1235. X#ifdef ATARI_ST
  1236. X    while (*ptr != ',' && *ptr != '\n' && *ptr != '\r' && *ptr)
  1237. X      obj_name[i++] = *ptr++;
  1238. X#else
  1239. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1240. X      obj_name[i++] = *ptr++;
  1241. X#endif
  1242. X    obj_name[i] = '\0';
  1243. X    if (*++ptr) obj_commnt = ptr;
  1244. X    else obj_commnt = "";
  1245. X      } else {
  1246. X    obj_type[0] = obj_type[1] = 'S'; /* Default SS single star */
  1247. X    obj_name[0] = '\0';
  1248. X    obj_commnt = "";
  1249. X      }
  1250. X    } else {
  1251. X      /*
  1252. X       * new reduced Yale catalog
  1253. X       */
  1254. X      m1 = fileline[11];
  1255. X      obj_mag = ((m1 == '-') ? -F2(12)/10.0 :
  1256. X         (m1 <= '9') ? F3(11)/100.0 : F3M(11)/100.0);
  1257. X      /* let's get Sirius */
  1258. X    
  1259. X      /*
  1260. X       * extract color, label, constellation, name, and comment
  1261. X       * Would be faster to just guarentee that the data file is correct
  1262. X       */
  1263. X      if (nchars > 22) {
  1264. X    obj_constell[0] = fileline[20];
  1265. X    obj_constell[1] = fileline[21];
  1266. X    obj_constell[2] = fileline[22];
  1267. X    obj_constell[3] = '\0';
  1268. X      }
  1269. X      if (nchars > 19) {
  1270. X    obj_label[0] = fileline[18];
  1271. X    obj_label[1] = fileline[19];
  1272. X    obj_label[2] = '\0';
  1273. X      }
  1274. X      if (nchars > 17) {
  1275. X    obj_color[0] = fileline[16]; 
  1276. X    obj_color[1] = fileline[17];
  1277. X    obj_color[2] = '\0';
  1278. X      }
  1279. X      if (nchars > 15) {
  1280. X    obj_type[0] = fileline[14];
  1281. X    obj_type[1] = fileline[15];
  1282. X      }
  1283. X
  1284. X      ptr = &fileline[MIN(23,nchars)];
  1285. X      i = 0;
  1286. X      while (*ptr == ' ') ptr++;
  1287. X#ifdef ATARI_ST
  1288. X      while (*ptr != ',' && *ptr != '\n' && *ptr != '\r' && *ptr)
  1289. X    obj_name[i++] = *ptr++;
  1290. X#else
  1291. X      while (*ptr != ',' && *ptr != '\n' && *ptr)
  1292. X    obj_name[i++] = *ptr++;
  1293. X#endif
  1294. X      obj_name[i] = '\0';
  1295. X      if (*++ptr) obj_commnt = ptr;
  1296. X      else obj_commnt = "";
  1297. X    }
  1298. X  }
  1299. X
  1300. X  return(FALSE); /* NO error */
  1301. X}
  1302. X
  1303. X/* Macintosh, under MPW, currently won't do buf_readstar */
  1304. X#ifndef macintosh
  1305. X#ifdef ATARI_ST
  1306. X#include<types.h>
  1307. X#include<stat.h>
  1308. X#else
  1309. X#include<sys/types.h>
  1310. X#include<sys/stat.h>
  1311. X#endif
  1312. X
  1313. X/* > MAXMAPFILES because more files may be read
  1314. X   if chart is changed interactively */
  1315. Xstruct fbuf {
  1316. X  char *name;
  1317. X  char *data;
  1318. X  char *cur_point;
  1319. X  char *last_point;
  1320. X} buf_files[10*MAXMAPFILES];
  1321. X
  1322. Xint nbuf_files = 0;
  1323. X
  1324. Xchar *last_read = "";
  1325. Xchar *cur_fpt = NULL;
  1326. Xchar *eodata = NULL;
  1327. Xint cur_buf = 0;
  1328. X
  1329. Xint buf_readstar(file, ftype)
  1330. X     FILE *file;
  1331. X     int ftype;
  1332. X{
  1333. X  int i;
  1334. X  struct stat fstats;
  1335. X  unsigned fsze;
  1336. X
  1337. X  char *ptr;
  1338. X  double rah, ram, ras, dld, dlm, dl, inten;
  1339. X  int nchars;
  1340. X  char m1;
  1341. X
  1342. X  if (ftype == GSCTYPE) return readstar(file, ftype);
  1343. X  /* We don't do buffered reads of the GSC data. */
  1344. X
  1345. X  /* if we've read this file before, access from memory
  1346. X     usually will be last read
  1347. X     Otherwise, try to allocate memory for file */
  1348. X
  1349. X  if (strcmp(cur_file_name, last_read)) {    /* New file, most likely */
  1350. X    for (i = 0; i < nbuf_files; i++)
  1351. X      if (!strcmp(cur_file_name, buf_files[i].name)) break;
  1352. X
  1353. X    if (i == nbuf_files) {    /* Need to read the file */
  1354. X      buf_files[nbuf_files].name =
  1355. X    (char *) malloc((unsigned) strlen(cur_file_name)+1);
  1356. X      strcpy(buf_files[nbuf_files].name, cur_file_name);
  1357. X
  1358. X#ifndef ATARI_ST
  1359. X      fstat(fileno(file), &fstats);
  1360. X#else
  1361. X      /* MWC 3.06 fstat is not implemented correctly. st_size is
  1362. X     always 0 (according to the manual !!) despite it's known. */
  1363. X      stat(cur_file_name, &fstats);
  1364. X#endif
  1365. X      fsze = fstats.st_size;
  1366. X      if (fsze != 0) {        /* e.g. /dev/null */
  1367. X    buf_files[nbuf_files].data = (char *) malloc(fsze);
  1368. X    if ((buf_files[nbuf_files].data == NULL)
  1369. X        || (((fsze = fread(buf_files[nbuf_files].data, 1,
  1370. X                   (int) fsze, file)) == 0)  /* no bytes read */
  1371. X        && (!feof(file)))) { /* And it's not the end of the file */
  1372. X      readfile = readstar;    /* Give up on buf_readstar */
  1373. X      D_comment("buffered file read: Out of memory\n");
  1374. X
  1375. X                /* call readstar now */
  1376. X      return readstar(file, ftype);
  1377. X    }
  1378. X      } else
  1379. X    buf_files[nbuf_files].data = "";
  1380. X
  1381. X      buf_files[nbuf_files].cur_point = buf_files[nbuf_files].data;
  1382. X      cur_fpt = buf_files[nbuf_files].cur_point;
  1383. X      buf_files[nbuf_files].last_point =
  1384. X    buf_files[nbuf_files].cur_point + fsze;
  1385. X      eodata = buf_files[nbuf_files].last_point;
  1386. X      last_read = buf_files[nbuf_files].name;
  1387. X      cur_buf = nbuf_files;
  1388. X      nbuf_files++;
  1389. X    } else {             /* Old file */
  1390. X/*      D_comment("Reading from memory\n");*/
  1391. X      last_read = buf_files[i].name;
  1392. X      cur_fpt = buf_files[i].cur_point = buf_files[i].data;
  1393. X      eodata = buf_files[i].last_point;
  1394. X      cur_buf = i;
  1395. X    }
  1396. X  }
  1397. X
  1398. X  /* Now, cur_fpt points to file data.  Read the data as in readstar above */
  1399. X  if ((ftype != LINEREAD) && (ftype != BINFULL)
  1400. X      && (ftype != BINOBJ) && (ftype != BINSTAR))
  1401. X    return (TRUE);
  1402. X  /* only LINEREAD, BINFULL, BINOBJ and BINSTAR supported at this time */
  1403. X
  1404. X  if (cur_fpt == eodata) return TRUE; /* End of data, end of file */
  1405. X
  1406. X
  1407. X  if (ftype == BINSTAR) {
  1408. X    for (i = 0, ptr = (char *) &binstar_in; i < sizeof(binstar_in); i++) 
  1409. X      *ptr++ = *cur_fpt++;
  1410. X    buf_files[cur_buf].cur_point += sizeof(binstar_in);
  1411. X
  1412. X    obj_lat = ((double) binstar_in.lat) / 3600000L;
  1413. X    obj_lon = ((double) binstar_in.lon) / 3600000L;
  1414. X    obj_mag = ((double) binstar_in.mag) / 1000L;
  1415. X    obj_type[0] = 'S';
  1416. X    obj_type[1] = 'S';
  1417. X    obj_color[0] = ' ';
  1418. X    obj_color[1] = ' ';
  1419. X    obj_label[0] = ' ';
  1420. X    obj_label[1] = ' ';
  1421. X    obj_constell[0] = ' ';
  1422. X    obj_constell[1] = ' ';
  1423. X    obj_constell[2] = ' ';
  1424. X    obj_name[0] = '\0';
  1425. X    obj_commnt = "";
  1426. X
  1427. X    strcpy(fileline, "");
  1428. X  } else if (ftype == BINOBJ) {
  1429. X    for (i = 0, ptr = (char *) &binobj_in; i < sizeof(binobj_in); i++) 
  1430. X      *ptr++ = *cur_fpt++;
  1431. X    buf_files[cur_buf].cur_point += sizeof(binobj_in);
  1432. X
  1433. X    obj_lat = ((double) binobj_in.lat) / 3600000L;
  1434. X    obj_lon = ((double) binobj_in.lon) / 3600000L;
  1435. X    obj_mag = ((double) binobj_in.mag) / 1000L;
  1436. X    obj_type[0] = binobj_in.type[0];
  1437. X    obj_type[1] = binobj_in.type[1];
  1438. X    obj_color[0] = ' ';
  1439. X    obj_color[1] = ' ';
  1440. X    obj_label[0] = ' ';
  1441. X    obj_label[1] = ' ';
  1442. X    obj_constell[0] = ' ';
  1443. X    obj_constell[1] = ' ';
  1444. X    obj_constell[2] = ' ';
  1445. X    obj_name[0] = '\0';
  1446. X    obj_commnt = "";
  1447. X
  1448. X    strcpy(fileline, "");
  1449. X  } else if (ftype == BINFULL) {
  1450. X    for (i = 0, ptr = (char *) &binfull_in; i < sizeof(binfull_in); i++) 
  1451. X      *ptr++ = *cur_fpt++;
  1452. X    buf_files[cur_buf].cur_point += sizeof(binfull_in);
  1453. X
  1454. X    if (binfull_in.strlen == 0)
  1455. X      strcpy(name_comment, "");
  1456. X    else {
  1457. X      for (i = 0; i < binfull_in.strlen; i++) 
  1458. X    name_comment[i] = *cur_fpt++;
  1459. X      buf_files[cur_buf].cur_point += binfull_in.strlen;
  1460. X
  1461. X      name_comment[binfull_in.strlen] = '\0';
  1462. X    }
  1463. X
  1464. X    obj_lat = ((double) binfull_in.lat) / 3600000L;
  1465. X    obj_lon = ((double) binfull_in.lon) / 3600000L;
  1466. X    obj_mag = ((double) binfull_in.mag) / 1000L;
  1467. X    obj_type[0] = binfull_in.tycolb[0];
  1468. X    obj_type[1] = binfull_in.tycolb[1];
  1469. X    obj_color[0] = binfull_in.tycolb[2];
  1470. X    obj_color[1] = binfull_in.tycolb[3];
  1471. X    obj_label[0] = binfull_in.tycolb[4];
  1472. X    obj_label[1] = binfull_in.tycolb[5];
  1473. X    strcpy(obj_constell,con_table[binfull_in.consindx]);
  1474. X
  1475. X    ptr = name_comment;
  1476. X    i = 0;
  1477. X    while (*ptr == ' ') ptr++;
  1478. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1479. X      obj_name[i++] = *ptr++;
  1480. X    obj_name[i] = '\0';
  1481. X    if ((*ptr == ',') && (*++ptr) && name_comment[0]) obj_commnt = ptr;
  1482. X    else obj_commnt = "";
  1483. X
  1484. X    strcpy(fileline, "");
  1485. X  } else { /* LINEREAD */
  1486. X
  1487. X/*
  1488. X * file formats:
  1489. X * new
  1490. X064509-1643-14SDA1a CMASirius
  1491. X051432-0812015SDB8b ORIRigel
  1492. X * old
  1493. X064509-1643-146SSSirius
  1494. X051432-08120015SSRigel
  1495. X */
  1496. X
  1497. X    ptr = fileline;
  1498. X    while ((*ptr++ = *cur_fpt++) != '\n');
  1499. X    *ptr = '\0';
  1500. X    buf_files[cur_buf].cur_point = cur_fpt;
  1501. X
  1502. X    nchars = 0;
  1503. X    while (fileline[nchars++]);
  1504. X    nchars--;
  1505. X    nchars--;
  1506. X
  1507. X/*
  1508. X * sscanf of floats is TOOO slow:
  1509. X *     sscanf(fileline, "%2f%2f%2f%c%2f%2f ... );
  1510. X * use alternate:
  1511. X */
  1512. X#define F2(i) (((fileline[i]-'0')*10.0+fileline[i+1]-'0'))
  1513. X#define F3(i) (((fileline[i]-'0')*100.0+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1514. X#define F4(i) (((fileline[i]-'0')*1000.0+(fileline[i+1]-'0')*100+(fileline[i+2])-'0')*10+fileline[i+3]-'0')
  1515. X#define F3M(i) (((fileline[i]-'A'+10.0)*100+(fileline[i+1]-'0')*10+fileline[i+2]-'0'))
  1516. X    rah = F2(0);
  1517. X    ram = F2(2);
  1518. X    ras = F2(4);
  1519. X    dld = F2(7);
  1520. X    dlm = F2(9);
  1521. X/*
  1522. X * common code
  1523. X */
  1524. X#define DLDEGSEC 3600.0
  1525. X#define DLMINSEC 60.0
  1526. X#define RAHRSSEC 54000.0
  1527. X#define RAMINSEC 900.0
  1528. X#define RASECSEC 15.0
  1529. X
  1530. X
  1531. X    obj_lon = (RAHRSSEC*rah + RAMINSEC*ram + RASECSEC*ras)/DLDEGSEC;
  1532. X    dl = (DLDEGSEC*dld + DLMINSEC*dlm)/DLDEGSEC;
  1533. X    obj_lat = (fileline[6]  == '-') ? -dl : dl;
  1534. X    
  1535. X    /* set unknowns to blanks */
  1536. X    obj_color[0] = ' ';
  1537. X    obj_color[1] = ' ';
  1538. X    obj_color[2] = '\0';
  1539. X    obj_label[0] = ' ';
  1540. X    obj_label[1] = ' ';
  1541. X    obj_label[2] = '\0';
  1542. X    obj_constell[0] = ' ';
  1543. X    obj_constell[1] = ' ';
  1544. X    obj_constell[2] = ' ';
  1545. X    obj_constell[3] = '\0';
  1546. X    
  1547. X    if  (isdigit(fileline[14])) {
  1548. X    /*
  1549. X     * old reduced Yale catalog
  1550. X     */
  1551. X      inten = F3(12);
  1552. X      if (fileline[11] == '0' || fileline[11] == '+') obj_mag = inten/100.0;
  1553. X      else if (fileline[11] == '-') obj_mag = -inten/100.0;
  1554. X      else obj_mag = F4(11)/1000.0;    /* new feature for stars >= 10.0 mag */
  1555. X      
  1556. X      if (nchars > 15) {
  1557. X    obj_type[0] = fileline[15];
  1558. X    obj_type[1] = fileline[16];
  1559. X    ptr = &fileline[MIN(17,nchars)];
  1560. X    i = 0;
  1561. X    while (*ptr == ' ') ptr++;
  1562. X    while (*ptr != ',' && *ptr != '\n' && *ptr)
  1563. X      obj_name[i++] = *ptr++;
  1564. X    obj_name[i] = '\0';
  1565. X    if (*++ptr) obj_commnt = ptr;
  1566. X    else obj_commnt = "";
  1567. X      } else {
  1568. X    obj_type[0] = obj_type[1] = 'S'; /* Default SS single star */
  1569. X    obj_name[0] = '\0';
  1570. X    obj_commnt = "";
  1571. X      }
  1572. X    } else {
  1573. X      /*
  1574. X       * new reduced Yale catalog
  1575. X       */
  1576. X      m1 = fileline[11];
  1577. X      obj_mag = ((m1 == '-') ? -F2(12)/10.0 :
  1578. X         (m1 <= '9') ? F3(11)/100.0 : F3M(11)/100.0);
  1579. X      /* let's get Sirius */
  1580. X    
  1581. X      /*
  1582. X       * extract color, label, constellation, name, and comment
  1583. X       * Would be faster to just guarentee that the data file is correct
  1584. X       */
  1585. X      if (nchars > 22) {
  1586. X    obj_constell[0] = fileline[20];
  1587. X    obj_constell[1] = fileline[21];
  1588. X    obj_constell[2] = fileline[22];
  1589. X    obj_constell[3] = '\0';
  1590. X      }
  1591. X      if (nchars > 19) {
  1592. X    obj_label[0] = fileline[18];
  1593. X    obj_label[1] = fileline[19];
  1594. X    obj_label[2] = '\0';
  1595. X      }
  1596. X      if (nchars > 17) {
  1597. X    obj_color[0] = fileline[16]; 
  1598. X    obj_color[1] = fileline[17];
  1599. X    obj_color[2] = '\0';
  1600. X      }
  1601. X      if (nchars > 15) {
  1602. X    obj_type[0] = fileline[14];
  1603. X    obj_type[1] = fileline[15];
  1604. X      }
  1605. X
  1606. X      ptr = &fileline[MIN(23,nchars)];
  1607. X      i = 0;
  1608. X      while (*ptr == ' ') ptr++;
  1609. X      while (*ptr != ',' && *ptr != '\n' && *ptr)
  1610. X    obj_name[i++] = *ptr++;
  1611. X      obj_name[i] = '\0';
  1612. X      if (*++ptr) obj_commnt = ptr;
  1613. X      else obj_commnt = "";
  1614. X    }
  1615. X  }
  1616. X
  1617. X  return(FALSE); /* NO error */
  1618. X}
  1619. X#endif /* macintosh */
  1620. END_OF_FILE
  1621. if test 22399 -ne `wc -c <'starchart/readfile.c'`; then
  1622.     echo shar: \"'starchart/readfile.c'\" unpacked with wrong size!
  1623. fi
  1624. # end of 'starchart/readfile.c'
  1625. fi
  1626. echo shar: End of archive 13 \(of 32\).
  1627. cp /dev/null ark13isdone
  1628. MISSING=""
  1629. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 ; do
  1630.     if test ! -f ark${I}isdone ; then
  1631.     MISSING="${MISSING} ${I}"
  1632.     fi
  1633. done
  1634. if test "${MISSING}" = "" ; then
  1635.     echo You have unpacked all 32 archives.
  1636.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1637. else
  1638.     echo You still need to unpack the following archives:
  1639.     echo "        " ${MISSING}
  1640. fi
  1641. ##  End of shell archive.
  1642. exit 0
  1643.  
  1644.